﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Net.Mail;

namespace XDLogonMonitor {
    class Email {
        private System.Net.Mail.SmtpClient smtpClient;
        
        public Email(String smtpServer) {
            try {
                smtpClient = new SmtpClient(smtpServer);
            }
            catch (Exception e) {
                Console.Error.WriteLine(e.ToString());
            }
        }
        public void Send(String from, String to, String subject, String message) {
            try {
                MailAddress maFrom = new MailAddress(from);
                MailAddress maTo = new MailAddress(to);
                MailMessage mmMessage = new MailMessage(maFrom, maTo);
                
                mmMessage.Body += message;
                mmMessage.Subject += subject;
                smtpClient.Send(mmMessage);
            }
            catch (Exception e) {
                Console.Error.WriteLine(e.ToString());
            }
        }
    }
}
